import request from "@/service/request.ts";
import {PromisePageResponse, PromiseResponse} from "@/service/api/type.ts";
import {
  CourseCourseVo,
  CourseGradeVo,
} from "@/service/api/course/core/types.ts";

/**
 * 获取年级列表
 * @param query
 */
const getGradeList = (query: any): PromisePageResponse<CourseGradeVo> => {
  return request({
    url: "/course/grade/list",
    method: "get",
    params: query,
  });
};

/**
 * 获取课程列表
 * @param query
 */
const getCourseList = (query: any): PromisePageResponse<CourseCourseVo> => {
  return request({
    url: "/course/course/list",
    method: "get",
    params: query,
  });
};

/**
 * 将课程添加到年级
 * @param gradeId
 * @param query
 */
const addCoursesToGrade = (gradeId: string, query: any): PromiseResponse<any> => {
  return request({
    url: `/course/course/addCore/${gradeId}`,
    method: "post",
    data: query,
  });
};

/**
 * 从年级移出课程
 * @param graideId
 * @param query
 */
const removeCoursesFromGrade = (query: any): PromiseResponse<any> => {
  return request({
    url: "/course/course/core",
    method: "put",
    data: query,
  });
};

/**
 * 设置核心课程顺序
 *
 */
const saveCoreCourseOrder = (gradeId: string, query: any): PromiseResponse<any> => {
  return request({
    url: `/course/course/core/${gradeId}`,
    method: "post",
    data: query,
  });
};

export {
  getGradeList,
  getCourseList,
  addCoursesToGrade,
  removeCoursesFromGrade,
  saveCoreCourseOrder,
};
